import java.security.spec.RSAOtherPrimeInfo;
import java.util.Scanner;

public class Test11 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num1 = sc.nextInt();
        int num2 = sc.nextInt();
        int [] n = new int [2];
        int result=1;
        n[1] =Integer.MAX_VALUE;
        n[0] =Integer.MAX_VALUE;

        for (int i = 1; i <= 10; i++) {
            if ((num1*i)%10 == 0) {
                if(i<= n[0]){
                    n[0] = i;
                }

            }
            if((num1*i-num2)%10 == 0){
                if(i<= n[1]){
                    n[1] = i;
                }

            }
        }

        System.out.println(n[0]<n[1]?n[0]:n[1]);
        //解法二
        while((num1*result)%10 != 0&&(num1*result)%10!=num2)result++;
        System.out.println(result);
    }
}
